local function gamemasterLook( cid, thing )
	local pos = getThingPos(thing)
	local msg = ""
	if(getPlayerAccess(cid) >= ACCESS_GAMEMASTER) then	
		if(isCreature(thing) == FALSE) then
			local item = getThing(thing)
			
			local itemArr =
			{
				item.itemid,
				item.actionid,
				item.uid,
				pos.x,
				pos.y,
				pos.z
			}
			
			local itemArrNames = { "ID", "AID", "UID", "X", "Y", "Z" }
			
			for i, v in pairs(itemArr) do
				if type(v) ~= "table" then
					if v ~= 0 and v < 70000 then					
						msg = msg .. "[" .. itemArrNames[i] .. ": " .. v .. "]"
					end
				else
					msg = msg .. "[" .. itemArrNames[i] .. ": " .. implode(v, "/") .. "]"
				end
			end	
			
			msg = "\n" .. msg
		else
			if( isPlayer( thing ) == TRUE ) then
				local playerArr =
				{
					getPlayerGUID(cid),
					{ getPlayerHealth(cid), getPlayerMaxHealth(cid) },
					{ getPlayerMana(cid), getPlayerMaxMana(cid) },
					getPlayerAccess(cid),
					pos.x,
					pos.y,
					pos.z
				}
				
				local playerArrNames = { "GUID", "HP", "MP", "Access", "X", "Y", "Z" }
				
				for i, v in pairs(playerArr) do
					if type(v) ~= "table" then
						if v ~= 0 and v < 70000 then					
							msg = msg .. "[" .. playerArrNames[i] .. ": " .. v .. "]"
						end
					else
						msg = msg .. "[" .. playerArrNames[i] .. ": " .. implode(v, "/") .. "]"
					end
				end				
			else
				local creatureArr =
				{
					{ getCreatureHealth(cid), getCreatureMaxHealth(cid) },
					pos.x,
					pos.y,
					pos.z
				}
				
				local creatureArrNames = { "HP", "X", "Y", "Z" }
				
				for i, v in pairs(creatureArr) do
					if type(v) ~= "table" then
						if v ~= 0 and v < 70000 then					
							msg = msg .. "[" .. creatureArrNames[i] .. ": " .. v .. "]"
						end
					else
						msg = msg .. "[" .. creatureArrNames[i] .. ": " .. implode(v, "/") .. "]"
					end
				end		
				
			end
			msg = "\n" .. msg
			
		end
	end
	
	return msg
end

function doorsLook( cid, thing )
	local msg = ""
	if isCreature( thing ) == FALSE then
		local item = getThing(thing)
		
		if( isItemDoor( item.itemid ) == TRUE ) then
			local pos = getThingPos(thing)
			dofile( getDataDir() .. "/game_classes/house.lua" )
			local house = House.getHouseByPos(pos)
			
			if house ~= nil then
				if house:getOwner() == FALSE then
					msg = "\nThis house is for sale. It costs " .. house:getPrice() .. " gold coins.\nThe rent is " .. house:getRent() .. "."
				end
			end
		end
	end
	
	return msg
end

function onLook(cid, thing)
	local msg = doorsLook(cid, thing) .. gamemasterLook(cid, thing)
	addScriptItemDescription( msg )

	return TRUE
	
end